/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.deployment;

import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.ActionRegistry;

import com.cea.papyrus.core.editor.DiagramPalette;
import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
import com.cea.papyrus.diagraminterchange2.di2.Diagram;

/**
 * Manages creation of the deployment diagram editor.
 * 
 * @author Gilles Cannenterre
 * @since 15 janv. 07
 */
public class DeploymentDiagramEditor extends AbstractGraphicalPageWithFlyoutPalette 
 {
	
	/**
	 * The PALETT e_ MODEL.
	 */
	private static DiagramPalette PALETTE_MODEL;    

	/**
	 * The Constructor.
	 * 
	 * @param diagram the diagram
	 * @param modelMngr the model mngr
	 */
	public DeploymentDiagramEditor( Diagram diagram, ModelManager modelMngr){
		super( diagram, modelMngr);		
	}

	/**
	 * Creates a new DeploymentDiagramEditor, with a specified editing domain.
	 * @param diagram the diagram displayed by this editor
	 * @param modelMngr the instance of the model manager for the edited model
	 * * @param commandStack the command stack shared among all editors of a multiDiagramEditor 
	 */
	public DeploymentDiagramEditor( Diagram diagram, ModelManager modelMngr, CommandStack commandStack, ActionRegistry actionRegistry){//, ModelResourceManager resourceManager){
		super( diagram, modelMngr, commandStack, actionRegistry);
	}
	
	/**
	 * In order to obtain the pallette Root.
	 * 
	 * @return the palette root
	 */
	@Override
	protected PaletteRoot getPaletteRoot() {
		if (PALETTE_MODEL == null) {
			PALETTE_MODEL = DeploymentDiagramPaletteFactory.createPalette();
		}
		return PALETTE_MODEL;
	}

	/**
	 * Configure graphical viewer.
	 */
	@Override
	protected void configureGraphicalViewer() {
		super.configureGraphicalViewer();

		viewer = getGraphicalViewer();

		// create and register the EditPartFactory
		viewer.setEditPartFactory(new DeploymentDiagramGraphicalEditPartsFactory(modelMngr));

		// configure the context menu provider
		cmProvider =
			new DeploymentDiagramContextMenuProvider(viewer, getActionRegistry(),modelMngr);
		super.configureContextMenuProvider();
	}
}